using System.Collections.Generic;
using System.Text.Json.Serialization;
using JlPay.Sdk.Models;
using JlPay.Sdk.Services;
using System;

namespace JlPay.Sdk.Models.Openmerch.Change
{
    /// <summary>
    /// 商户信息变更请求
    /// </summary>
    public class MerchInfoChangeRequest : OrgBaseRequest, IRequestMapper
    {
        /// <summary>
        /// API URL
        /// </summary>
        public const string API_URL = "/open/merch/access/merch-info/modify";

        /// <summary>
        /// 商户基础信息
        /// </summary>
        [JsonPropertyName("base_info")]
        public Dictionary<string, object>? BaseInfo { get; set; }

        /// <summary>
        /// 商户业务信息
        /// </summary>
        [JsonPropertyName("business_info")]
        public Dictionary<string, object>? BusinessInfo { get; set; }

        /// <summary>
        /// 结算信息
        /// </summary>
        [JsonPropertyName("settle_info")]
        public Dictionary<string, object>? SettleInfo { get; set; }

        /// <summary>
        /// 商户身份信息
        /// </summary>
        [JsonPropertyName("identification_info")]
        public Dictionary<string, object>? IdentificationInfo { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public MerchInfoChangeRequest()
        {
            // 添加敏感字段
            AddSensitiveField("identification_info.id_card_name");
            AddSensitiveField("identification_info.id_card_english_name");
            AddSensitiveField("identification_info.id_card_no");
            AddSensitiveField("identification_info.legal_person_phone");
        }

        /// <summary>
        /// 转换为字典
        /// </summary>
        /// <returns>字典对象</returns>
        public Dictionary<string, object> ToMap()
        {
            var map = new Dictionary<string, object>();

            // 添加基础字段（可选）
            if (!string.IsNullOrEmpty(OrgNo))
                map["org_no"] = OrgNo;
            if (!string.IsNullOrEmpty(MerchNo))
                map["merch_no"] = MerchNo;

            // 添加复杂对象字段
            if (BaseInfo != null && BaseInfo.Count > 0)
                map["base_info"] = BaseInfo;
            if (BusinessInfo != null && BusinessInfo.Count > 0)
                map["business_info"] = BusinessInfo;
            if (SettleInfo != null && SettleInfo.Count > 0)
                map["settle_info"] = SettleInfo;
            if (IdentificationInfo != null && IdentificationInfo.Count > 0)
                map["identification_info"] = IdentificationInfo;

            return map;
        }
    }
} 